﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace InSiteExtractor.Configuration
{
    class ConfigurationHelper
    {
        static public string GetRowFileter(string tableName)
        {
            string rowFilter = null;

            MapSettingsSection mapSection = (MapSettingsSection)ConfigurationManager.GetSection("mapSettings");

            foreach (MapSettingElement item in mapSection.MapSettings)
            {
                if (item.Name.ToUpper() == tableName.ToUpper())
                {
                    rowFilter = item.Filter;
                    break;
                }
            }

            return rowFilter;
        }

        static public string ConvertTableName(string tableName)
        {
            string convertedName = tableName;

            MapSettingsSection mapSection = (MapSettingsSection)ConfigurationManager.GetSection("mapSettings");

            foreach (MapSettingElement item in mapSection.MapSettings)
            {
                if (item.Name.ToUpper() == tableName.ToUpper())
                {
                    convertedName = item.NewName;
                    break;
                }
            }

            return convertedName;
        }
    }
}
